﻿using System.Data;
using System.Data.SqlClient;
using EntitiesTM;

namespace DataAccess
{
    public class DaActivity
    {
        public DataTable selActivityByProjectID(int projectID, string companyid)
        {
            string strCommandText = "selActivityByProjectID" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[1];
            paraLocal[0] = new SqlParameter("@ProjectID", projectID);
            return SqlHelper.ExecuteData(CommandType.StoredProcedure, strCommandText, paraLocal);
        }
        public DataTable selActivityByProjectID2(int projectID, string companyid)
        {
            string strCommandText = "selActivityByProjectIDTmp" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[1];
            paraLocal[0] = new SqlParameter("@ProjectID", projectID);
            return SqlHelper.ExecuteData(CommandType.StoredProcedure, strCommandText, paraLocal);
        }

        public DataTable selTotalTime(int projectID, string companyid)
        {
            string strCommandText = "selTotalTime" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[1];
            paraLocal[0] = new SqlParameter("@ProjectID", projectID);
            return SqlHelper.ExecuteData(CommandType.StoredProcedure, strCommandText, paraLocal);
        }

        public DataTable selActivityByID(int activityID, string companyid)
        {
            string strCommandText = "selActivityByID" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[1];
            paraLocal[0] = new SqlParameter("@ActivityID", activityID);
            return SqlHelper.ExecuteData(CommandType.StoredProcedure, strCommandText, paraLocal);
        }

        public DataTable selActivityByID2(int activityID, string companyid)
        {
            string strCommandText = "selActivityByIDTmp" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[1];
            paraLocal[0] = new SqlParameter("@ActivityID", activityID);
            return SqlHelper.ExecuteData(CommandType.StoredProcedure, strCommandText, paraLocal);
        }

        public void updActivity(EnActivity activity, string companyid)
        {
            string strCommandText = "updActivity" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[3];
            paraLocal[0] = new SqlParameter("@ActivityName", activity.activityName);
            paraLocal[1] = new SqlParameter("@ActivityEstimateTime", activity.activityEstimateTime);
            paraLocal[2] = new SqlParameter("@ActivityID", activity.activityID);
            SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, strCommandText, paraLocal);
        }

        public void updActivity2(EnActivity activity, string companyid)
        {
            string strCommandText = "updActivityTmp" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[4];
            paraLocal[0] = new SqlParameter("@ActivityName", activity.activityName);
            paraLocal[1] = new SqlParameter("@ActivityEstimateTime", activity.activityEstimateTime);
            paraLocal[2] = new SqlParameter("@ActivityID", activity.activityID);
            paraLocal[3] = new SqlParameter("@ActivityCode", activity.activityCode);
            SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, strCommandText, paraLocal);
        }

        public void delActivity(int activityID, string companyid)
        {
            string strCommandText = "delActivity" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[1];
            paraLocal[0] = new SqlParameter("@ActivityID", activityID);
            SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, strCommandText, paraLocal);
        }

        public void delSAActivity(int activityID, string companyid)
        {
            string strCommandText = "delSAActivity" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[1];
            paraLocal[0] = new SqlParameter("@ActivityID", activityID);
            SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, strCommandText, paraLocal);
        }

        public DataTable selReportTimeActivity(int activityID, string companyid)
        {
            string strCommandText = "selReportTimeActivity" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[1];
            paraLocal[0] = new SqlParameter("@ActivityID", activityID);
            return SqlHelper.ExecuteData(CommandType.StoredProcedure, strCommandText, paraLocal);
        }

        public DataTable selReportTimeActivityPerUser(int activityID, string companyid)
        {
            string strCommandText = "selReportTimeActivityPerUser" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[1];
            paraLocal[0] = new SqlParameter("@ActivityID", activityID);
            return SqlHelper.ExecuteData(CommandType.StoredProcedure, strCommandText, paraLocal);
        }
    }
}
